Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser errors from within includes should not be rescueable #73722

Merged
merged 3 commits into from
Nov 1, 2021

Conversation

mkrizek
Copy link
Contributor

@mkrizek mkrizek commented Feb 25, 2021

SUMMARY

Fixes #73657

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/plugins/strategy/__init__.py
lib/ansible/plugins/strategy/free.py
lib/ansible/plugins/strategy/linear.py

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Feb 25, 2021
@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Feb 25, 2021
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 1, 2021
@@ -470,6 +479,8 @@ def _queue_put(item, *args, **kwargs):

mock_inc_file._filename = "test.yml"
res = strategy_base._load_included_file(included_file=mock_inc_file, iterator=mock_iterator)
self.assertEqual(len(res), 1)
self.assertTrue(isinstance(res[0], Block))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change actually revealed an issue with this unit test.

The mocks caused the parent task to have collections set as a MagicMock instance resulting in debug not being found and _load_included_file throwing AnsibleParserError which was then shadowed by AnsibleError and _load_included_file returned an empty list. The res was not asserted in any way and the test passed.

With this PR AnsibleParserError is thrown instead of being shadowed by AnsibleError, the unit test failed with AnsibleParserError. Now the mocks are "fixed" and the result checked for expected result.

@mkrizek mkrizek requested review from bcoca and sivel March 1, 2021 14:19
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 9, 2021
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jun 8, 2021
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Nov 1, 2021
@bcoca bcoca merged commit 47ee282 into ansible:devel Nov 1, 2021
@mkrizek mkrizek deleted the issue-73657 branch November 1, 2021 15:16
@ansible ansible locked and limited conversation to collaborators Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block with rescue stops next plays and end playbook successfully on some errors
4 participants